package thread;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-09-23
 * Time: 10:50
 */
public class ThreadDemon26 {
    public static volatile int flag = 0;

    public static void main(String[] args) {

        Thread t1 = new Thread(()->{
            while(flag == 0){//等待t1线程输入flag的值，只要不为0就能结束t1线程


            }
            System.out.println("t1线程结束");
        });
        Thread t2 = new Thread(()->{
            System.out.println("请输入flag的值");
            Scanner scanner = new Scanner(System.in);
            flag = scanner.nextInt();
        });

        t1.start();
        t2.start();
    }
}
